<?php
class IndexAction extends BaseAction{

	public function _initialize() {
		parent::_initialize();
	}

    public function index(){

        //$pSystemUserGroup = D('SystemUserGroup');
 		$this->display();
    }

    //菜单
	function menu() {
		$appList = array(
			'initial'=>array('title'=>'首页','url'=>__APP__.'&mod=Index&act=menulist&id=1'),
			'user'=>array('title'=>'用户','url'=>__APP__.'&mod=Index&act=menulist&id=3'),
			'application'=>array('title'=>'应用','url'=>__APP__.'&mod=Index&act=menulist&id=4'),
			'system'=>array('title'=>'高级','url'=>__APP__.'&mod=Index&act=menulist&id=2')
		);
		exit(json_encode($appList));
//        $pNode = D('SystemNode');
//        $list = $pNode->where("pid=0 AND type='admin' AND state=1")->order('ordernum ASC')->findall();
//        foreach ($list as $val){
//        	$name = $val['name'];
//        	$data[$name]['title'] = $val['title'];
//        	$data[$name]['url']   =  __APP__.'/Index/menulist/id/'.$val['id'];
//        }
//		exit(json_encode($data));
	}

	//左侧列表
	function menulist(){

		$intId = intval($_GET['id']);
		if($intId=='1'){
			echo '{
			"Home":{"title":"常用操作","node":[
			    {"title":"后台管理日志","url":"index.php?app=admin&mod=Log&act=index"},
				{"title":"数据清理","url":"index.php?app=admin&mod=Clean&act=index"},
				{"title":"附件管理","url":"index.php?app=admin&mod=System&act=attach"},
				{"title":"动态管理","url":"index.php?app=admin&mod=System&act=feed"},
				{"title":"投票管理","url":"index.php?app=admin&mod=System&act=vote"},
				{"title":"标签过滤","url":"index.php?app=admin&mod=Tag&act=index"},
				{"title":"统计报表","url":"index.php?app=admin&mod=Contribute&act=index"},
				{"title":"小工具","url":"index.php?app=portal&mod=data"}
			]},
			"Info":{"title":"信息发布","node":[
				{"title":"\u6587\u7ae0\u5217\u8868","url":"index.php?app=admin&mod=Cms&act=index"},
				{"title":"\u6dfb\u52a0\u6587\u7ae0\u5206\u7c7b","url":"index.php?app=admin&mod=Cms&act=addCategory"},
				{"title":"\u6dfb\u52a0\u6587\u7ae0","url":"index.php?app=admin&mod=Cms&act=addContent"}
			]}
			}';
		}
		if($intId=='3'){
			echo '{
			"User":{"title":"用户管理","node":[
				{"title":"用户管理","url":"index.php?app=admin&mod=User&act=index"},
				{"title":"用户组管理","url":"index.php?app=admin&mod=Popedom&act=group"},
				{"title":"消息群发","url":"index.php?app=admin&mod=User&act=msg"},
				{"title":"工号切换","url":"index.php?app=admin&mod=User&act=changeCardId"}
			]}
			}';
		}
		if($intId=='4'){
			echo '{
			"Apps":{"title":"应用管理","node":[
				{"title":"问答管理","url":"index.php?app=ask&mod=Admin"},
				{"title":"空间管理","url":"index.php?app=space&mod=Admin"},
				{"title":"博客管理","url":"index.php?app=blog&mod=Admin&act=bloglist"},
				{"title":"团队空间","url":"index.php?app=group&mod=Admin&act=index"},
				{"title":"论坛管理","url":"index.php?app=bbs&mod=Admin&act=index"},
				{"title":"百科管理","url":"index.php?app=wiki&mod=Admin&act=index"},
				{"title":"专题管理","url":"index.php?app=portal&mod=Channel&act=admin"}
			]}
			}';
		}
		if($intId=='2'){
			echo '{
			"System":{"title":"高级操作","node":[
				{"title":"邮件管理","url":"index.php?app=admin&mod=System&act=email"},
				{"title":"积分规则","url":"index.php?app=admin&mod=System&act=scores"},
				{"title":"认证设置","url":"index.php?app=admin&mod=System&act=domain"},
				{"title":"计划任务","url":"index.php?app=admin&mod=System&act=schedule"},
				{"title":"密码生成","url":"index.php?app=admin&mod=System&act=makePassword"}
			]}
			}';
		}
		//{"title":"安全测试","url":"index.php?app=admin&mod=System&act=security"}

//        $pNode = D('SystemNode');
//        $list = $pNode->getNodeList($intId);
//    	foreach ($list as $val){
//    		foreach ($val['child'] as $key=>$cval){
//    			$a['title'] = $cval['title'];
//    			$a['url']   = __APP__.'/'.$val['name'].'/'.$cval['name'];
//    			$node[]     = $a;
//    		}
//    		$b['title'] = $val['title'];
//    		$b['node']  = $node;
//    		unset($node);
//    		$name = $val['name'];
//    		$data[$name] = $b;
//    	}
//    	if($intId==4){
//			$apps = D("App")->where("status!=2")->findAll();
//			foreach($apps as $k=>$v){
//				$APP_URL = str_replace('http://{APPS_URL}',SITE_URL.'/apps',$v['url']);
//				$open_apps[$k]["title"] = $v["name"];
//				$open_apps[$k]["url"]   = str_replace('http://{APP_URL}',$APP_URL,$v['url_admin']);
//			}
//			$data['Apps']['node'] = $open_apps;
//    	}
//    	exit(json_encode($data));
	}
}
?>